#include <bits/stdc++.h>
 
using namespace std;
 
bool hasIntersection(const int *range1, const int *range2) {
    int s1 = range1[0];
    int e1 = range1[1];
 
    int s2 = range2[0];
    int e2 = range2[1];
 
    if (s1 == s2) return true;
    else if (s1 < s2) return e1 >= s2;
    else return e2 >= s1;
}
 
int main() {
    int n;
    cin >> n;
 
    vector<int *> used;
    used.emplace_back(new int[2]{100, 101});
 
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
 
        unsigned long long pos = s.find('=');
 
        string key = s.substr(0, pos);
        string val = s.substr(pos + 1);
 
        if (key == "REQUEST") {
            int size = stoi(val);
 
            if (size == 0) {
                cout << "error" << endl;
                continue;
            }
 
            int start = 0;
            bool flag = true;
 
            for (int j = 0; j < used.size(); j++) {
                int end = start + size - 1;
 
                int *range = new int[2]{start, end};
 
                if (!hasIntersection(used[j], range)) {
                    used.insert(used.begin() + j, range);
                    flag = false;
                    cout << start << endl;
                    break;
                } else {
                    start = used[j][1] + 1;
                }
            }
 
            if (flag) cout << "error" << endl;
        } else {
            int addr = stoi(val);
 
            if (addr >= 100) {
                cout << "error" << endl;
                continue;
            }
 
            bool flag = true;
 
            for (int j = 0; j < used.size(); j++) {
                if (used[j][0] == addr) {
                    used.erase(used.begin() + j);
                    flag = false;
                    break;
                }
            }
 
            if (flag) cout << "error" << endl;
        }
    }
 
    return 0;
}